package com.example.springboot159.util;

import com.google.common.util.concurrent.RateLimiter;
import java.util.concurrent.TimeUnit;

public class RateLimiterUtils {
    public static boolean tryAcquire(Integer limit,Integer timeout) {
        return RateLimiter.create(limit).tryAcquire(timeout, TimeUnit.MILLISECONDS);
    }

    public static double acquire(Integer limit) {
        return RateLimiter.create(limit).acquire(limit);
    }

}
